import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

public class PersonalRecommendorTest {

    public Map<String, LinkedList<String>> getLikes() {

        LinkedList<String> linkedList1 = new LinkedList<>();
        LinkedList<String> linkedList2 = new LinkedList<>();
        LinkedList<String> linkedList3 = new LinkedList<>();

        linkedList1.add("1");
        linkedList1.add("2");
        linkedList1.add("3");
        linkedList1.add("4");
        linkedList1.add("5");

        linkedList2.add("a");
        linkedList2.add("b");
        linkedList2.add("c");

        linkedList3.add("a");
        linkedList3.add("b");
        linkedList3.add("c");
        linkedList3.add("3");

        Map<String, LinkedList<String>> map = new HashMap<>();
        map.put("A", linkedList1);
        map.put("B", linkedList2);
        map.put("C", linkedList3);

        return map;
    }

    @Test
    public void addLikesTest() {
        PersonalRecommender personalRecommender = new PersonalRecommender();
        personalRecommender.setLikes(getLikes());
        personalRecommender.addLikes("A", "e");
        Assert.assertTrue(personalRecommender.getLikes().get("A").contains("e"));
    }

    @Test
    public void likeBothTest() {
        PersonalRecommender personalRecommender = new PersonalRecommender();
        personalRecommender.setLikes(getLikes());
        Assert.assertTrue(personalRecommender.likeBoth("A", "1", "5"));
        Assert.assertFalse(personalRecommender.likeBoth("B", "3", "5"));
    }

    @Test
    public void recommendByPersonTest() {
        PersonalRecommender personalRecommender = new PersonalRecommender();
        personalRecommender.setLikes(getLikes());
        LinkedList<String> linkedList = new LinkedList<>(personalRecommender.recommendByPerson("A"));
        Assert.assertTrue(linkedList.contains("1"));
        Assert.assertTrue(linkedList.contains("2"));
        Assert.assertTrue(linkedList.contains("3"));
        Assert.assertTrue(linkedList.contains("4"));
        Assert.assertTrue(linkedList.contains("5"));
        Assert.assertTrue(linkedList.contains("a"));
        Assert.assertTrue(linkedList.contains("b"));
        Assert.assertTrue(linkedList.contains("c"));

        Assert.assertFalse(linkedList.contains("e"));
    }

    @Test
    public void recommendByProjectTest() {
        PersonalRecommender personalRecommender = new PersonalRecommender();
        personalRecommender.setLikes(getLikes());
        LinkedList<String> linkedList = new LinkedList<>(personalRecommender.recommendByProject("3"));

        Assert.assertTrue(linkedList.contains("1"));
        Assert.assertTrue(linkedList.contains("2"));
        Assert.assertTrue(linkedList.contains("3"));
        Assert.assertTrue(linkedList.contains("4"));
        Assert.assertTrue(linkedList.contains("5"));
        Assert.assertTrue(linkedList.contains("a"));
        Assert.assertTrue(linkedList.contains("b"));
        Assert.assertTrue(linkedList.contains("c"));
    }
}
